
/**
 * Example of a Fenetre (JFrame) using awt and swing
 * @author your_name
 */

 import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

 public class Fenetre extends JFrame implements ActionListener {

 /** a label for the name */
 private JLabel label1;
 private JLabel label2;
 /** a textfield for the name */
 private JTextField text;
 /** a button to perform an action: e.g. say hello (TBD) */
 private JButton button;
 

 /** Creates a Fenetre */
 public Fenetre() {
   initComponents();
 }
 
 public void actionPerformed(ActionEvent E){
	 this.remove(label2);
	 label2 = new JLabel("Hello "+text.getText());
	 this.add("South",label2);
	 this.pack();
 }

 /** Initializes the Fenetre components */

 private void initComponents() {
 // create the components
 // a new label with the "Nom" as value
 label1 = new JLabel("Nom: ");
 label2= new JLabel();
 // a new text field with 20 columns
 text = new JTextField(20);
 // a new button identified as OK
 button = new JButton("OK");
 button.addActionListener(this);
 // configures the JFrame layout using a border layout
 this.setLayout(new BorderLayout());
 // places the components in the layout
 this.add("West",label1);
 this.add("Center",text);
 this.add("East",button);
 // packs the fenetre: size is calculated
 // regarding the added components
 this.pack();
 // the JFrame is visible now
 this.setVisible(true);
 }

 /** main entry point */
 public static void main(String[] args) {
    Fenetre f = new Fenetre();
  }
}